package com.kania.todostack;

import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;

public class TodoView extends TextView{
	int left = 0, top = 0, right = 100, bottom = 10;
	TodoData tdData;
	Handler hMain;

	public TodoView(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
	}
	
	public TodoView(Context context, TodoData td, Handler handler){
		super(context);
		tdData = td;
		hMain = handler;
		this.setText(tdData.getTodo());
		this.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 8.0f);
		this.setPadding(5, 1, 1, 1);
		this.setGravity(Gravity.CENTER_VERTICAL);
		this.setTextColor(Color.WHITE);
		this.setBackgroundColor(Color.BLACK);
		this.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Message msg = Message.obtain();
				Bundle data = new Bundle();
				data.putInt("eventtype", Type.EVENTTPYE_TODO_INFO);
				data.putString("todoinfo", tdData.getTodo());
				data.putInt("subinfo", tdData.getSubject());
				data.putInt("id", tdData.getID());
				msg.setData(data);
				hMain.sendMessage(msg);
			}
		});
	}
	
	/*
	public void onMeasure(int widthMeasuredSpec, int heightMeasuredSpec){
		setMeasuredDimension(viewWidth, viewHeight);
	}
	*/
}